//
//  ChatModelFrame.m
//  QQ界面
//
//  Created by apple on 16/11/18.
//  Copyright © 2016年 LWB. All rights reserved.
//

#import "ChatModelFrame.h"
#import "ChatModel.h"
#import "NSString+StringTosize.h"
@implementation ChatModelFrame
-(void)setChatModel:(ChatModel *)chatModel{
    _chatModel = chatModel;
    
    CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
    CGFloat margin = 5;
    _timeFrame = CGRectMake(0,15, screenW, 15);
    
    CGFloat iconW = 40;
    CGFloat iconH = 40;
    CGFloat iconY = CGRectGetMaxY(_timeFrame) + margin+10;
    CGFloat iconX = (chatModel.type == MessageTypeMe)?(screenW - iconW - margin):margin;
    _iconframe =CGRectMake(iconX,iconY,iconW, iconH);
    
    
    CGSize textSize = [chatModel.text sizeOfTextWithMaxSize:CGSizeMake(200, MAXFLOAT) font:[UIFont systemFontOfSize:14]];
    CGFloat textX =(chatModel.type == MessageTypeMe)?(screenW-iconW-margin*2-textSize.width-40):(CGRectGetMaxX(_iconframe)+margin);
    CGFloat textY = iconY+margin-2;
    CGFloat textW = textSize.width+40;
    CGFloat textH = textSize.height+35;
    _textFrame = CGRectMake(textX, textY, textW, textH);
    _rowHeight = MAX(CGRectGetMaxY(_iconframe), CGRectGetMaxY(_textFrame));
    
}
@end
